<!--
 * @Author: Zhouxin 2201_75539691@noreply.gitcode.com
 * @Date: 2024-12-02 20:37:13
 * @LastEditors: Zhouxin 2201_75539691@noreply.gitcode.com
 * @LastEditTime: 2024-12-02 20:47:05
 * @FilePath: \2024.12.2-day12-工厂模式 自定义构造函数 this\1hw.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //第一种
        var obj1 = {
            name: "zz",
            age: 21
        }


        //第二种
        function create(name, age, sex) {
            var obj2 = new Object();
            obj2.name = name;
            obj2.age = age;
            obj2.sex = sex;
            return obj2;
        }

        var obj2 = create('zz', 21, 'Man');

        //第三种

        function Student(name, age, sex) {
            this.name = name;
            this.age = age;
            this.sex = sex;
        }

        var obj3 = new Student('zz', 21, 'Man');
        console.log(obj1.name, obj2.age, obj3.sex);
    </script>
</body>

</html>